package cn.calm.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.TableGenerator;

import cn.calm.commons.entity.BaseEntity;

@Entity(name = "faq")
public class Faq implements BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@TableGenerator(name = "FAQ_SEQ", table = "sequence", pkColumnName = "KEYID", valueColumnName = "KEYVALUE", pkColumnValue = "FAQ_ID",allocationSize=1)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "FAQ_SEQ")
	private String id;
	@ManyToOne
	@JoinColumn(name="PRTENT_ID")
	private Faq parent;
	private String status;
	private String title;
	@OneToMany(mappedBy="parent")
	private Set<Faq> subFaqs;
	private String content;
	@Override
	public Object getValue() {
		return getId();
	}

	@Override
	public String getDisplayName() {
		return "FAQ";
	}

	public Faq getParent() {
		return parent;
	}

	public void setParent(Faq parent) {
		this.parent = parent;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Set<Faq> getSubFaqs() {
		if (subFaqs == null) {
			subFaqs = new HashSet<Faq>();
		}
		return subFaqs;
	}

	public void setSubFaqs(Set<Faq> subFaqs) {
		this.subFaqs = subFaqs;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
}
